<!DOCTYPE html >
<html perf-error="desktop/" ng-app="eleme" class="ng-scope" id='document'>
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title class="ng-binding" ng-bind="SEO.title">饿了么-网上订餐_外卖_饿了么订餐官网</title>
    <link rel="stylesheet" type="text/css" href="{{asset('home/cart/css/index.css')}}
            " media="all">
</head>
<body class="hidesidebar" style="position: relative;" cute-title=""
      ng-class="{hidesidebar: layoutState &amp;&amp; layoutState.hideSidebar, smallbody: layoutState.smallBody, whitebody: layoutState.whiteBody}">

<div class="ng-isolate-scope" state="layoutState" ng-switch="state.type"><!-- ngSwitchWhen: checkout -->
    <header ng-switch-when="checkout" topbar-checkout="" state="state" class="carttopbar">
        <div class="carttopbar-nav container clearfix"><span class="carttopbar-nav-path">当前位置：<a
                        href="{{asset('')}}place/wx4spk2q4gx" class="ng-binding" ng-href="/place/wx4spk2q4gx"
                        ng-bind="$root.place.name || $root.place.address">{{$data->business_address}}</a> <i
                        class="icon-arrow-right"></i> <a href="{{asset('')}}shop/1300459"
                                                         class="inherit ng-binding" ng-href="/shop/1300459"
                                                         ng-bind="state.rstName"
                                                         ng-show="state.rstName">{{$data->username}}</a> <i
                        class="icon-arrow-right" ng-show="state.rstName"></i> 订单信息</span>
            <div topbar-profilebox="">
                <div class="topbar-profilebox"><!-- ngIf: $root.user.avatar && $root.topbarType !== 'checkout' -->
                    <span class="topbar-profilebox-avatar icon-profile" ng-show="!$root.user.username"></span>
                    <span class="" ng-show="!$root.user.username"><a href="{{asset('')}}login"
                                                                     ng-href="{{asset('')}}login"
                                                                     target="_blank">登录</a>/<a
                                href="{{asset('')}}register" ng-href="{{asset('')}}register"
                                target="_blank">注册</a></span>
                    <span class="topbar-profilebox-wrapper ng-hide"
                          ng-show="$root.user.username"><!-- ngIf: $root.topbarType === 'checkout' --> <span
                                class="topbar-profilebox-username ng-binding"></span>
                        <!-- ngIf: $root.topbarType === 'checkout' -->
                        <!-- ngIf: $root.topbarType !== 'checkout' -->
<span
        class="topbar-profilebox-btn icon-arrow-down ng-scope"
        ng-if="$root.topbarType !== 'checkout'"></span>
                        <!-- end ngIf: $root.topbarType !== 'checkout' -->
<div
        class="dropbox topbar-profilebox-dropbox"><a class="icon-profile"
                                                     href="{{asset('')}}profile"
                                                     hardjump="">个人中心</a>  <a
            class="icon-location" href="{{asset('')}}profile/address" hardjump="">我的地址</a> <a
            class="icon-logout" href="javascript:" ng-click="logout()">退出登录</a></div></span>
                </div>
            </div>
        </div>
    </header><!-- ngSwitchDefault:  -->
</div>
<div class="importantnotification container" role="banner"><!-- ngIf: enable -->
</div>
<div ng-hide="layoutState &amp;&amp; layoutState.hideSidebar" class="sidebar ng-hide" role="complementary">
    <div class="sidebar-tabs">
        <div class="toolbar-tabs-middle"><a class="toolbar-btn icon-order toolbar-close"
                                            href="{{asset('')}}profile/order" hardjump="" tooltip="我的订单"
                                            tooltip-placement="left" ubt-click="toolbar_order">
                <!-- ngIf: sidebarCount.uncompletedOrder > 0 -->
            </a>
            <div class="toolbar-separator"></div>
            <a class="toolbar-cartbtn icon-cart toolbar-open toolbar-cartbtn-shownum" href="javascript:" template="cart"
               ng-class="{'focus': (activeTemplate === 'cart' &amp;&amp; isSidebarOpen), 'toolbar-cartbtn-shownum': foodCount.count}"
               ubt-click="390">购物车<!-- ngIf: foodCount.count -->
                <i class="toolbar-cartnum ng-binding ng-scope"
                   ng-if="foodCount.count"
                   ng-bind="foodCount.count">2</i>
                <!-- end ngIf: foodCount.count -->
            </a>
            <div class="toolbar-separator"></div>
            <a class="toolbar-btn icon-notice toolbar-open modal-hide" href="javascript:" template="message"
               ng-class="{'focus': (activeTemplate === 'message' &amp;&amp; isSidebarOpen), 'toolbar-open': user, 'modal-hide': user}"
               tooltip="我的信息" tooltip-placement="left" ubt-click="392"><!-- ngIf: messageCount.count -->
            </a></div>
        <div class="toolbar-tabs-bottom">
            <div class="toolbar-btn icon-QR-code">
                <div class="dropbox toolbar-tabs-dropbox"><a
                            href="http://static11.elemecdn.com/eleme/desktop/mobile/index.html" target="_blank"><img
                                src="{{asset('home/cart/images/appqc.95e532.png')}}"
                                alt="下载手机应用">
                        <p>下载手机应用</p>
                        <p class="icon-QR-code-bonus">即可参加分享红包活动</p></a></div>
            </div>
            <a style="visibility: visible;" class="toolbar-btn icon-service" online-service="" tooltip="在线客服"
               title="在线客服" tooltip-placement="left" id="live800iconlink" target="_blank" href="javascript:"></a> <a
                    style="visibility: hidden;" class="toolbar-btn sidebar-btn-backtop icon-top" tooltip="回到顶部"
                    title="回到顶部" href="javascript:" tooltip-placement="left"></a></div>
    </div>
    <div class="sidebar-content">
        <!-- ngInclude: activeTemplate ? ('/common/page/_block/sidebar/sidebar-'+ activeTemplate + '/sidebar-'+ activeTemplate + '.html') : '' -->
    </div>
</div>
<!-- ngView:  -->
<div class="ng-scope" ng-view="" role="main">
    <div checkout-guide="" guide="guide" class="checkoutguide ng-isolate-scope">
        <div class="container"><a class="checkoutguide-logo icon-logo" href="{{asset('')}}"></a> <span
                    class="checkoutguide-text ng-binding" ng-bind="guide.text">订单信息</span><!-- ngIf: guide.step -->
            <div class="checkoutguide-content step2" ng-if="guide.step"><span class="checkoutguide-item active"
                                                                              ng-class="{active: guide.step >= 1}">选择商品</span>
                <span class="checkoutguide-item active" ng-class="{active: guide.step >= 2}">确认订单信息</span> <span
                        class="checkoutguide-item" ng-class="{active: guide.step >= 3}">成功提交订单</span>
                <p class="checkoutguide-line"><span class="line line1"></span> <span class="line line2"></span> <span
                            class="line line3"></span> <span class="line line4"></span></p></div>
            <!-- end ngIf: guide.step -->
        </div>
    </div>
    <div class="container clearfix ng-scope"><!-- ngIf: loading -->
        <!-- ngIf: !loading && nofood -->
        <!-- ngIf: !loading && !nofood -->
        <div ng-if="!loading &amp;&amp; !nofood" class="checkout-cart ng-scope ng-isolate-scope" checkout-cart="cart">
            <div class="checkoutcart-container">
                <div class="checkoutcart-title"><h2>订单详情</h2><a href="{{asset('')}}shop/1300459"
                                                                ng-href="/shop/1300459">&lt; 返回商家修改</a></div>
                <div class="checkoutcart-tablerow tablehead">
                    <div class="cell itemname">商品</div>
                    <div class="cell itemquantity">份数</div>
                    <div class="cell itemtotal">小计（元）</div>
                </div><!-- ngRepeat: basket in cart.vm.group -->
                <!-- ngIf: basket.length -->
                <dl ng-if="basket.length" ng-repeat="basket in cart.vm.group" class="checkoutcart-group ng-scope">
                    <dt ng-bind="$index + 1 + '号购物车'" class="checkoutcart-grouptitle ng-binding">1号购物车</dt>
                    <!-- ngRepeat: item in basket -->
                    {{--TODO: dd item--}}
                </dl><!-- end ngIf: basket.length -->
                <!-- end ngRepeat: basket in cart.vm.group -->
                <!-- ngIf: cart.vm.extra || cart.vm.records -->
                <ul class="ng-scope" ng-if="cart.vm.extra || cart.vm.records"><!-- ngRepeat: item in cart.vm.extra -->
                    <li ng-repeat="item in cart.vm.extra" class="checkoutcart-tablerow extra ng-scope">
                        <div class="cell itemname"><span class="ng-binding" ng-bind="item.name" title="餐盒">餐盒</span>
                            <!-- ngIf: item.name === '配送费' -->
                        </div>
                        <div class="cell itemquantity"></div>
                        <div class="cell itemtotal" ng-class="{minus: item.price < 0}"
                             ng-bind="'¥' + (item.price | number:2)">¥2.00
                        </div>
                    </li><!-- end ngRepeat: item in cart.vm.extra -->
                    <li ng-repeat="item in cart.vm.extra"
                        class="checkoutcart-tablerow  checkoutcart-send-costs extra ng-scope">
                        <div class="cell itemname"><span class="ng-binding" ng-bind="item.name" title="配送费">配送费</span>
                            <!-- ngIf: item.name === '配送费' -->
                            <span ng-if="item.name === '配送费'"
                                  class="icon-circle-help ng-scope" tooltip=""
                                  tooltip-placement="left"></span>
                            <!-- end ngIf: item.name === '配送费' -->
                        </div>
                        <div class="cell itemquantity"></div>
                        <div class="cell itemtotal" ng-class="{minus: item.price < 0}"
                             ng-bind="'¥' + (item.price | number:2)">¥3.00
                        </div>
                    </li><!-- end ngRepeat: item in cart.vm.extra -->
                    <!-- ngRepeat: item in cart.vm.records -->
                </ul>
                <!-- end ngIf: cart.vm.extra || cart.vm.records -->
                <div class="checkoutcart-total color-stress">¥<span class="num ng-binding"
                                                                    ng-bind="cart.vm.total | number: 2"></span>
                </div>
                <div class="checkoutcart-totalextra">共 <span class="ng-binding" ng-bind="cart.pieces">2</span> 份商品
                    <!-- ngIf: cart.vm.benefit -->
                </div>
            </div>
        </div><!-- end ngIf: !loading && !nofood -->
        <!-- ngIf: !loading && !nofood -->
        <div ng-if="!loading &amp;&amp; !nofood" class="checkout-content ng-scope">
            <div class="checkout-select ng-isolate-scope" checkout-address="" checkout-data="checkoutData"
                 address-list="addressList" address="address" isbaisheng="isBaishengRst"><h2>收货地址 <a
                            ng-show="addressList.length" class="checkout-addaddress ng-hide" href="javascript:"
                            ng-click="javascript:addAddress()">添加新地址</a></h2><!-- ngIf: !addressList.length -->
                <a
                        class="checkout-noaddress ng-scope" ng-if="!addressList.length" href="javascript:"
                        ng-click="addAddress()">+ 添加新地址</a><!-- end ngIf: !addressList.length -->
                <ul ng-hide="!addressList.length" class="checkout-address-list ng-hide"
                    ng-class="{ showmore: showMoreAddress, showfirst: noInitAddress }">
                    <!-- ngRepeat: item in addressList -->
                    <a class="checout-showmoreaddress ng-hide" href="javascript:"
                       ng-click="showMoreAddress = true"
                       ng-show="!showMoreAddress &amp;&amp; addressList.length > 1">显示更多地址<i
                                class="icon-arrow-down"></i></a> <a class="checout-showmoreaddress ng-hide"
                                                                    href="javascript:"
                                                                    ng-click="showMoreAddress = false"
                                                                    ng-show="showMoreAddress &amp;&amp; addressList.length > 1">收起<i
                                class="icon-arrow-up"></i></a></ul>
            </div>
            <div class="checkout-select"><h2 class="checkout-title">付款方式<span class="color-tip checkout-pay-tip">推荐使用在线支付，不用找零，优惠更多</span>
                </h2>
                <ul class="clearfix"><!-- ngRepeat: pay in payList -->
                    <li class="checkout-pay ng-scope onlinepay" ng-repeat="pay in payList"
                        ng-click="selectPay(pay.id, pay.disabled)"
                        ng-class="{active: payId === pay.id, disabled: pay.disabled}" tooltip=""><p class="ng-binding"
                                                                                                    ng-bind="pay.title">
                            在线支付</p>
                        <p class="color-mute ng-binding" ng-bind="pay.tip">支持微信、支付宝、QQ钱包及大部分银行卡</p></li>
                    <!-- end ngRepeat: pay in payList -->
                    <li class="checkout-pay ng-scope getpay" ng-repeat="pay in payList"
                        ng-click="selectPay(pay.id, pay.disabled)"
                        ng-class="{active: payId === pay.id, disabled: pay.disabled}" tooltip="该商家仅支持在线支付"><p
                                class="ng-binding" ng-bind="pay.title">货到付款</p>
                        <p class="color-mute ng-binding" ng-bind="pay.tip">送货上门后再付款</p></li>
                    <!-- end ngRepeat: pay in payList -->
                </ul>
            </div>
            <div class="checkout-select"><h2 class="checkout-title">选择优惠</h2>
                <p class="checkout-info"><span class="checkout-infolabel">使用红包</span> <span class="color-mute">无可用红包
                        <!-- ngIf: checkout.hongbaoCount -->
</span></p>
                <p class="checkout-info"><span class="checkout-infolabel">使用优惠券</span> <span class="color-mute">网站不支持<em
                                class="color-stress">（仅手机客户端可用）</em></span></p></div>
            <div class="checkout-select"><h2 class="checkout-title">其他信息</h2>
                <div class="checkout-info"><span class="checkout-infolabel">配送方式</span> <span>本订单由<a
                                class="ng-binding send_from"
                                ng-bind="' [' + delivery + '] '"> [小蜀娘家常菜] </a>提供配送</span>
                </div>
                {{--TODO: 送达时间--}}
                <div class="checkout-info" ng-show="showDeliverTime"><span class="checkout-infolabel">送达时间</span>
                    <div formselect="" data="bookTimes" choosed="time" selectfn="updateDeliverTime"
                         class="formselect ng-isolate-scope"><span class="formselect-value ng-binding">立即送达</span>
                        <div class="formselect-data ui-scrollbar-light"><!-- ngRepeat: item in data -->
                            <span
                                    class="ng-binding ng-scope" ng-repeat="item in data"
                                    ng-click="select($event, item)"
                                    ng-class="{active: (selected === item &amp;&amp; !item.disabled), disabled: item.disabled}">立即送达<i
                                        class="icon-check"></i>
                            </span><!-- end ngRepeat: item in data -->
                        </div>
                        <i class="icon-arrow-down"></i></div>
                </div>
                <div class="checkout-info"><span class="checkout-infolabel">发票信息</span> <span class="checkout-invoice"
                                                                                              ng-mouseenter="toggleInvoice($event)"
                                                                                              ng-mouseleave="toggleInvoice($event)"><input
                                disabled="disabled" class="checkout-input ng-pristine ng-valid" placeholder="商家不支持开发票"
                                ng-disabled="!checkoutData.invoice.is_available" ng-model="invoiceRef.invoiceValue"
                                ng-change="updateInvoice(invoiceRef.invoiceValue)"><ul
                                class="checkout-invoice-list ng-hide" ng-show="showInvoice"><!-- ngRepeat: item in invoices -->
</ul></span>
                </div>
                <div class="checkout-info"><span class="checkout-infolabel">订单备注</span> <span><input
                                class="checkout-input ng-pristine ng-valid" ng-model="note"
                                name="order_bak"
                                ng-change="updateDescription(note)"></span></div>
            </div>
            <div>
                <button quicksubmit-trigger="" submit-visable="checkout.submitVisable"
                        class="btn-stress btn-lg ng-binding ng-isolate-scope"
                        ng-bind="orderButton.text" ng-click="orderSubmit()">
                </button>
                <div class="checkout-dapp"><p class="checkout-dapp-tip">扫码下载APP<br>APP下单立享优惠</p><i
                            class="icon-qrcode checkout-dapp-qrcode"></i> <i
                            class="icon-uniE029 checkout-dapp-arrow"></i> <img
                            src="{{asset('home/cart/images/appqc.95e532.png')}}"

                            alt="扫一扫下载饿了么手机 App"></div>
            </div>
        </div><!-- end ngIf: !loading && !nofood -->
    </div>
</div>
<footer class="footer" role="contentinfo">
    <div class="container clearfix">
        <div class="footer-link"><h3 class="footer-link-title">用户帮助</h3><a class="footer-link-item"
                                                                           href="{{asset('')}}support/center"
                                                                           target="_blank">服务中心</a> <a
                    class="footer-link-item" href="{{asset('')}}support/question/default" target="_blank">常见问题</a>
            <a style="visibility: visible;" class="footer-link-item" online-service="" href="javascript:">在线客服</a></div>
        <div class="footer-link"><h3 class="footer-link-title">商务合作</h3><a class="footer-link-item"
                                                                           href="https://kaidian.ele.me/"
                                                                           target="_blank">我要开店</a> <a
                    class="footer-link-item" href="{{asset('')}}support/about/jiameng" target="_blank">加盟指南</a> <a
                    class="footer-link-item" href="{{asset('')}}support/about/contact" target="_blank">市场合作</a> <a
                    class="footer-link-item" href="https://opensite.ele.me/help.html" target="_blank">开放平台</a></div>
        <div class="footer-link"><h3 class="footer-link-title">关于我们</h3><a class="footer-link-item"
                                                                           href="{{asset('')}}support/about"
                                                                           target="_blank">饿了么介绍</a> <a
                    class="footer-link-item" href="http://jobs.ele.me/" target="_blank">加入我们</a> <a
                    class="footer-link-item" href="{{asset('')}}support/about/contact" target="_blank">联系我们</a> <a
                    class="footer-link-item" href="{{asset('')}}support/rules/default" target="_blank">规则中心</a>
        </div>
        <div class="footer-contect">
            <div class="footer-contect-item">24小时客服热线 : <a class="inherit" href="tel:10105757">10105757</a></div>
            <div class="footer-contect-item">意见反馈 : <a class="inherit" href="mailto:feedback@ele.me">feedback@ele.me</a>
            </div>
            <div class="footer-contect-item">关注我们 :
                <div href="JavaScript:" class="icon-wechat" ubt-click="402">
                    <div class="dropbox dropbox-bottom footer-contect-dropbox" ubt-visit="402"><img
                                src="{{asset('home/cart/images/wexinqc100@2x.393ade.png')}}"
                                alt="微信号: elemeorder">
                        <p>微信号: elemeorder</p>
                        <p>饿了么网上订餐</p></div>
                </div>
                <a href="http://e.weibo.com/elemeorder" class="icon-weibo" target="_blank"></a></div>
        </div>
        <div class="footer-mobile"><a href="https://h.ele.me/landing" target="_blank"><img
                        src="{{asset('home/cart/images/appqc.95e532.png')}}"

                        class="footer-mobile-icon"
                        alt="扫一扫下载饿了么手机 App"></a>
            <div class="footer-mobile-content"><h3>下载手机版</h3>
                <p>扫一扫,手机订餐方便</p></div>
        </div>
        <div class="footer-copyright serif">增值电信业务许可证 : <a href="http://www.shca.gov.cn/"
                                                           target="_blank">沪B2-20150033</a> | <a
                    href="http://www.miibeian.gov.cn/" target="_blank">沪ICP备 09007032</a> | <a
                    href="http://www.sgs.gov.cn/lz/licenseLink.do?method=licenceView&amp;entyId=20120305173227823"
                    target="_blank">上海工商行政管理</a> Copyright ©2008-2016 ele.me, All Rights Reserved.
        </div>
        <div class="footer-police container"><a href="http://www.zx110.org/picp/?sn=310100103568" rel="nofollow"
                                                target="_blank"><img alt="已通过沪公网备案，备案号 310100103568"
                                                                     src="{{asset('home/cart/images/picp_bg.e373b3.jpg')}}"
                                                                     height="30"></a></div>
    </div>
</footer>

{{--添加地址弹窗开始--}}
<div ng-init="unclick"
     style="position: fixed; left: 0px; top: 0px; width: 100%; height: 100%; opacity: 0.5; background: rgb(0, 0, 0) none repeat scroll 0% 0%; z-index: 1000;"></div>
<div style="left: 288px; top: 95.5px; z-index: 1001;" class="addressdialog" ng-init="unclick">
    <div class="addressdialog-close"></div>
    <div class="addressdialog-header">添加新地址</div>
    <div class="addressdialog-content">
        <div class="addressform">
            <div>
                <div class="addressformfield getmanfield"><label>姓名</label><input placeholder="请输入您的姓名">
                    <div class="addressformfield-hint"><span></span></div>
                </div>
                <div class="addressformfield sexfield"><label>性别</label>
                    <div><input value="1" name="sex" id="sexfield-1-male" type="radio"><label
                                for="sexfield-1-male">先生</label><input value="2" name="sex" id="sexfield-1-female"
                                                                       type="radio"><label
                                for="sexfield-1-female">女士</label></div>
                    <div class="addressformfield-hint"><span></span></div>
                </div>
                <div class="addressformfield addressfield"><label>位置</label><img
                            src="">
                    <input placeholder="请输入小区、大厦或学校" class="address_input">
                    <div class="address-suggestlist">
                        <ul class="address-suggestlist-ul">
                        </ul>
                    </div>

                    <div class="addressformfield-hint"><span></span></div>
                    <div style="display: none;" class="addressform-tip">
                        <p><span>没找到你的地址？</span><a
                                    style="display: none;">去地图看看吧！</a></p>
                        <p>请尝试只输入小区、大厦或学校看看。</p>
                        <div class="arrow"></div>
                    </div>
                </div>
                <div class="addressformfield detailaddressfield"><label>详细地址</label><input placeholder="单元、门牌号">
                    <div class="addressformfield-hint"><span></span></div>
                </div>
                <div class="addressformfield phonefield"><label>手机号</label><input placeholder="请输入您的手机号">
                    <div class="addressformfield-hint"><span></span></div>
                </div>
            </div>
            <div class="addressform-buttons">
                <button class="addressform-buttons-save">保存</button>
                <button class="addressform-buttons-canle">取消</button>
            </div>
        </div>
    </div>
</div>
{{--添加地址弹窗结束--}}
</body>

<script src="{{asset('home/blade/js/jquery-1.8.3.min.js')}}" type="text/javascript"></script>

<script>

    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });

    //    TODO: 提交数据声明
    var detail_id = 0;      //  详情ID
    var address_id = 0;
    var useremail = '';
    var getmanfield = '';
    var sexfield = '';
    var addressfield = '';
    var detailaddressfield = '';
    var phonefield = '';
    //    // 初始化登录状态
    //    var islogin = '';
    //    $.get('/shop/islogin/ajax', {}, function (data) {
    //        // data 存在值说明已经登录过
    //        if (data) {
    //            islogin = data;     // 本页面保存状态
    //            $(".topbar-profilebox-avatar").attr('class', 'topbar-profilebox-avatar icon-profile ng-hide');
    //            $(".topbar-profilebox-avatar").next().attr('class', 'ng-hide');
    //            $(".topbar-profilebox-username").html(data);
    //            $(".topbar-profilebox-avatar").next().next().attr('class', 'topbar-profilebox-wrapper');
    //        }
    //    }, 'json');
    //
    //    // 退出登录 logout
    //    $(".icon-logout").on('click', function () {
    //        window.location.href = "/shop/logout/cart";
    //    });

    //    右边订单处理
    checkout();
    function checkout() {
        //    隐藏添加地址弹窗
        $("div[ng-init='unclick']").css('display', 'none');
        //    隐藏搜索结果框
        $("div[class='address-suggestlist']").css('display', 'none')


        //    当点击添加地址时显示添加地址弹窗
        $("a[ng-click='addAddress()']").on('click', function () {
            $("div[ng-init='unclick']").fadeIn();

        });

        //    点击关闭时,关闭地址弹窗
        $("div[class='addressdialog-close']").on('click', function () {
            $("div[ng-init='unclick']").fadeOut();
        });

        // 地址页面表单 拍空格动态显示地址
        $(".addressfield input").on('keydown', function (ent) {

            if (ent.keyCode != 13) {
            } else {
                $("div[class='address-suggestlist']").slideDown();

                var addressfield = $(this);
                $.post("/addaddress", {address: $(this).val()}, function (data) {
                    if (data['data'] == '') {
                        $(".addressform-tip").css('display', 'block');
                        $(".address-suggestlist").css('display', 'none');
                    } else {

                        $(".address-suggestlist").css('display', 'block');
                        $(".addressform-tip").css('display', 'none');

                        var liStr = '';
                        $.each(data['data'], function (i) {
                            liStr += '<li><div class="name"></div><div class="address">' + data['data'][i]['address'] + '</div></li>';
                        });
                        $(".address-suggestlist ul").append(liStr);
                        $.each($(".address-suggestlist ul li"), function (i) {
                            $(this).on('click', function () {
                                $(".address_input").val($(this).text());
                            });
                        });
                    }

                }, 'json');
            }

        });
        //    addressformfield

        var errorCode = 0;

        // 编辑地址 点击保存时
        // 声明action行为状态为save
        $(".addressform-buttons-save").on('click', function () {
            $.each($(".addressformfield").find("input"), function (i) {
                if ($(this).val() == '') {
                    errorCode++;
                    $(this).parent().attr('class', 'addressformfield validate-error');
                    var errorStr = '<div class="addressformfield-hint"><span class="icon-dot-error">信息不能为空</span></div>';
                    $(this).parent().append(errorStr);
                } else {
//                $(this).parents().find(".addressformfield").attr('class', 'addressformfield');
//                var errorStr = '<div class="addressformfield-hint"><span class="icon-dot-error">信息不能为空</span></div>';
                }
            });
            // 判断 如果全部填写完成 替换成固定地址
            if (errorCode == 0) {

                $("div[ng-init='unclick']").fadeOut();

                // 声明地址信息变量
                useremail = $(".topbar-profilebox-username").html();
                getmanfield = $("div[class='addressformfield getmanfield'] input").val();
                sexfield = $("div[class='addressformfield sexfield'] input[name='sex']").val();
                addressfield = $("div[class='addressformfield addressfield'] input").val();
                detailaddressfield = $("div[class='addressformfield detailaddressfield'] input").val();
                phonefield = $("div[class='addressformfield phonefield'] input").val();

                address_str = '<li ng-mouseenter="selectAddress($event, item)" ng-class="{active: address.id === item.id}" ng-click="selectAddress($event, item)" ng-repeat="item in addressList" class="checkout-address ng-scope active"><i class="checkout-address-icon icon-location-line"></i><div class="checkout-address-info"><p class="ng-binding">尹天 先生 15272007542</p><p ng-bind="item.address + item.address_detail" class="color-weak ng-binding">兄弟连IT教育1a02</p></div><div class="checkout-address-edit"><a class="editAddress" href="javascript:">修改</a> <a ng-click="removeAddress($event, item)" href="javascript:">×</a></div><!-- ngIf: !item.st_geohash --><!-- ngIf: !item.is_deliverable --><!-- ngIf: item.st_geohash && item.poi_type === 1 && isbaisheng --></li>';

                // 修改样式 替换地址
                $(".checkout-noaddress").remove();
                $(".checkout-address-list").attr('class', 'checkout-address-list showfirst');
                $(".checkout-address-list").replaceWith(address_str);

                // 替换选择后的地址信息
                $("div[class='checkout-address-info'] .color-weak").prev().html(getmanfield + ' 先生 ' + phonefield);
                $("div[class='checkout-address-info'] .color-weak").html(addressfield + detailaddressfield);

                // 发送postAjax保存数据
                $.post('/address/cart_shop/saveaddressajax', {
                    'address_id': address_id,
                    'useremail': useremail,
                    'getmanfield': getmanfield,
                    'sexfield': sexfield,
                    'addressfield': addressfield,
                    'detailaddressfield': detailaddressfield,
                    'phonefield': phonefield,
                }, function (data) {
                    address_id = data;
                }, 'json');

            }
            errorCode = 0;

            // 点击编辑时 显示编辑地址表单
            $(".editAddress").on('click', function () {
                // 修改action行为状态为 edit
                action = 'edit';
                $("div[ng-init='unclick']").fadeIn();
            });
        });

        // 地址失去焦点时触发
        $(".addressfield input").on('blur', function () {

            $("div[class='address-suggestlist']").slideUp();

        });

        // 支付方式选择 开始
        $(".clearfix .onlinepay").attr('class', 'checkout-pay ng-scope onlinepay active');
        $(".clearfix .getpay").attr('class', 'checkout-pay ng-scope getpay unactive');
        $(".clearfix .getpay").on('click', function () {
            $(".clearfix .onlinepay").attr('class', 'checkout-pay ng-scope onlinepay unactive');
            $(".clearfix .getpay").attr('class', 'checkout-pay ng-scope getpay active');
        });

        $(".clearfix .onlinepay").on('click', function () {
            $(".clearfix .getpay").attr('class', 'checkout-pay ng-scope getpay unactive');
            $(".clearfix .onlinepay").attr('class', 'checkout-pay ng-scope onlinepay active');
        });
        // 支付方式选择 结束

        // 时间选择 开始
        $("div[selectfn='updateDeliverTime']").on('mouseover', function () {
            $(".formselect-data").attr('class', 'formselect-data ui-scrollbar-light show');
        });
        $("div[selectfn='updateDeliverTime']").on('mouseout', function () {
            $(".formselect-data").attr('class', 'formselect-data ui-scrollbar-light');
        });
        var today = new Date();
        var h = today.getHours();
        var m = today.getMinutes();
        var q_m = Math.ceil(m / 15);      // q_m 当前小时的刻
        var h_i = 0;        // h_i 根据当前小时的刻钟判断要增加的小时
        var r_h = '';        // 右边的小时
        var r_m = '';        // 右边的分钟
        var nexttime = '';
        var strTime = '';
        var strTimeAll = '';

        for (var i = 0; i < (23 - h) * 4; i++) {
            r_m_a = q_m++ * 15;
            h_i = r_m_a / 60;
            r_h = Math.floor(h + 1 + h_i);
            r_m = Math.ceil((q_m - 1) % 4) * 15;

            if (r_m == 0) {
                r_m = '00';
            }

            if (nexttime == '') {
                nexttime = r_h + ":" + r_m;
                continue
            }

            strTime = nexttime + " - " + r_h + ":" + r_m;
            strTimeAll = '<span class="ng-binding ng-scope" ng-repeat="item in data" ng-click="select($event, item)" >' + strTime + '<i class="icon-check"></i> </span><!-- end ngRepeat: item in data -->';

            $(".formselect-data").append(strTimeAll);
            nexttime = r_h + ":" + r_m;

        }

        $.each($(".formselect span"), function () {
            $(this).on('click', function () {
                $(".formselect-value").text($(this).text());
                $(this).nextAll().attr('class', 'ng-binding ng-scope')
                $(this).prevAll().attr('class', 'ng-binding ng-scope')
                $(this).attr('class', 'ng-binding ng-scope active')

                $(".formselect-data").attr('class', 'formselect-data ui-scrollbar-light');
            });
        });
        // 时间选择 结束

    }

    //    左边购物车处理
    shopcart();
    function shopcart() {

//        初始化配送费
        var send_costs = '{{$data->send_costs}}';
        var business_name = '{{$data->username}}';
        var start_send_costs = '{{$data->start_send_costs}}';

        var total = 0;


        $.get('/shop/cart_shop/ajax', function (data) {

            var item_num = 0;

            $.each(data, function () {

                item_num++;
                console.log($(this));

                shopStr = '' +
                        '<dd ng-repeat="item in basket"class="ng-scope">' +
                        '<div class="checkoutcart-tablerow">' +
                        '<div title="' + $(this)[0]['proname'] + '"ng-bind="item.name"class="cell itemname ng-binding">' + $(this)[0]['proname'] + '</div>' +
                        '<div class="cell itemquantity">' +
                        '<button class="cart_sub_item">-</button>' +
                        '<input  class="ng-pristine ng-valid" value=' + $(this)[0]['num'] + '>' +
                        '<button class="cart_add_item">+</button>' +
                        '</div>' +
                        '<div class="cell itemtotal ng-binding">¥' + $(this)[0]['price'] + '</div>' +
                        '</div>' +
                        '</dd>';

                var item = $(this);
                detail_id = item[0]['id'];


//                $(".checkoutcart-group").append(shopStr);
                if ($(this)[0]['num'] > 0) {
                    $(".checkoutcart-group").append(shopStr);
                }

//                如果没有商品item 就显示区下单
                if (!$("dd[class='ng-scope']").is('dd')) {

                    null_cart_str = '<div class="container clearfix ng-scope"><!-- ngIf: loading --><!-- ngIf: !loading && nofood --><div class="nodata ng-isolate-scope" content="你的购物车是空的，去下单吧"><p ng-bind-html="content | toTrusted" class="nodata-container ng-binding">你的购物车是空的，去<a href="/place/{{$data->id}}">下单</a>吧</p></div><!-- end ngIf: !loading && nofood --><!-- ngIf: !loading && !nofood --><!-- ngIf: !loading && !nofood --></div>';

                    $("div[class='container clearfix ng-scope']").replaceWith(null_cart_str);

                }


                total = $(this)[0]['price'] * $(this)[0]['num'];

                $(".checkoutcart-totalextra span").html(item_num);      // 更新购物车商品数量

                $(".checkoutcart-send-costs .itemtotal ").html('¥' + send_costs + '.00');       //  更新购物车配送费

                // 点击 - 时 商品 -1
                $("button[class='cart_sub_item']").on('click', function () {

                    $("input[class='ng-pristine ng-valid']").attr('value', parseInt($("input[class='ng-pristine ng-valid']").attr('value')) - 1);
                    var item_input_num = $("input[class='ng-pristine ng-valid']").attr('value');

//                    TODO: 减
                    if ($("input[class='ng-pristine ng-valid']").attr('value') < 1) {
                        $(".cart_sub_item").parent().parent().parent().remove();

                        item_input_num = 0;

                    }

                    $.post('/shop/cart_shop_as/ajax',
                            {'detail_id': item[0]['id'], 'num': item_input_num},
                            function (data) {

                                if (!data) {
                                    null_cart_str = '<div class="container clearfix ng-scope"><!-- ngIf: loading --><!-- ngIf: !loading && nofood --><div class="nodata ng-isolate-scope" content="你的购物车是空的，去下单吧"><p ng-bind-html="content | toTrusted" class="nodata-container ng-binding">你的购物车是空的，去<a href="/place/{{$data->id}}">下单</a>吧</p></div><!-- end ngIf: !loading && nofood --><!-- ngIf: !loading && !nofood --><!-- ngIf: !loading && !nofood --></div>';

                                    $("div[class='container clearfix ng-scope']").replaceWith(null_cart_str);
                                }


                                total = data['price'] * data['num'];
                                $(".checkoutcart-totalextra span").html(item_num);      // 更新购物车商品数量


                                initCart();
                            },
                            'json');

                });

                // 点击 + 时 商品 +1
                $("button[class='cart_add_item']").on('click', function () {

//                    total += parseInt($(this)[0]['price']) * parseInt($(this)[0]['num']);
//
//                    $(".checkoutcart-totalextra span").html(item_num);      // 更新购物车商品数量

                    $("input[class='ng-pristine ng-valid']").attr('value', parseInt($("input[class='ng-pristine ng-valid']").attr('value')) + 1);
                    var item_input_num = $("input[class='ng-pristine ng-valid']").attr('value');
                    $.post('/shop/cart_shop_as/ajax',
                            {'detail_id': item[0]['id'], 'num': item_input_num},
                            function (data) {
                                total = data['price'] * data['num'];
                                $(".checkoutcart-totalextra span").html(item_num);      // 更新购物车商品数量


                                initCart();
                            },
                            'json');
                });


            });

            initCart();


        }, 'json');

        function initCart() {

            total += parseInt(send_costs) + 2;

            $("div[class='cell itemtotal ng-binding']").html('¥' + (total - parseInt(send_costs) - 2) + '.00');
            $(".checkoutcart-total span").html(total);      //  更新购物车总价

            $("span[class='quick-text'] .total").html(total);       //  更新订单总价

            $("span a[class='ng-binding send_from']").html(' [' + business_name + '] ');        //  更新商家总价

            // 判断提交按钮状态
            if (total < start_send_costs) {
                var drt_s = parseInt(start_send_costs) - total
                $(".btn-stress").html('还差' + drt_s + '元起送');
                $(".btn-stress").attr('disabled', true);
            } else {
                $(".btn-stress").html('确认下单');
                $(".btn-stress").attr('disabled', false);
            }
        }


    }

    // 却认下单 提交订单
    $(".btn-stress").on('click', function () {

        if (address_id == 0) {
            alert('地址未添加');
        } else {
            var bussiness_id = "{{$data->id}}";     // 商家ID
            // detail_id        详情ID
            // useremail        用户邮箱
            // address_id       地址ID
            var payway = "2";     // 支付方式
            var sendway = "{{$data->username}}";    // 配送方式
            var get_time = $(".formselect-value").html();       // 送货时间
            var order_bak = $("input[name='order_bak']").val();     // 订单备注


            $.post("/order/insert", {
                'bussiness_id': bussiness_id,
                'detail_id': detail_id,
                'user_email': useremail,
                'address_id': address_id,
                'payway': payway,
                'sendway': sendway,
                'get_time': get_time,
                'order_bak': order_bak
            }, function (data) {
                if (data) {
                    window.location.href = "/order/complete/" + data;
                }
            }, 'json');
        }

    });

</script>
</html>
